<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Bomberman:  Fichier source de /home/ph3w/Bureau/lif7-bomberman/ClientServer/Client/class_client.cpp</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Généré par Doxygen 1.7.1 -->
<script type="text/javascript">
function hasClass(ele,cls) {
  return ele.className.match(new RegExp('(\\s|^)'+cls+'(\\s|$)'));
}

function addClass(ele,cls) {
  if (!this.hasClass(ele,cls)) ele.className += " "+cls;
}

function removeClass(ele,cls) {
  if (hasClass(ele,cls)) {
    var reg = new RegExp('(\\s|^)'+cls+'(\\s|$)');
    ele.className=ele.className.replace(reg,' ');
  }
}

function toggleVisibility(linkObj) {
 var base = linkObj.getAttribute('id');
 var summary = document.getElementById(base + '-summary');
 var content = document.getElementById(base + '-content');
 var trigger = document.getElementById(base + '-trigger');
 if ( hasClass(linkObj,'closed') ) {
   summary.style.display = 'none';
   content.style.display = 'block';
   trigger.src = 'open.png';
   removeClass(linkObj,'closed');
   addClass(linkObj,'opened');
 } else if ( hasClass(linkObj,'opened') ) {
   summary.style.display = 'block';
   content.style.display = 'none';
   trigger.src = 'closed.png';
   removeClass(linkObj,'opened');
   addClass(linkObj,'closed');
 }
 return false;
}
</script>
<div class="header">
  <div class="headertitle">
<h1>/home/ph3w/Bureau/lif7-bomberman/ClientServer/Client/class_client.cpp</h1>  </div>
</div>
<div class="contents">
<a href="class__client_8cpp.html">Aller à la documentation de ce fichier.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#include &quot;<a class="code" href="class__client_8h.html">class_client.h</a>&quot;</span>
<a name="l00002"></a>00002 <span class="preprocessor">#include &quot;../../debug.h&quot;</span>
<a name="l00003"></a>00003 
<a name="l00004"></a>00004 
<a name="l00005"></a>00005 <span class="comment">/***************************************************************************/</span><span class="comment">/*!</span>
<a name="l00006"></a>00006 <span class="comment">* @fn client::client()</span>
<a name="l00007"></a>00007 <span class="comment">* @brief Constructeur par défaut</span>
<a name="l00008"></a>00008 <span class="comment">* @note L&#39;adresse par défaut de connection au serveur est 127.0.0.1</span>
<a name="l00009"></a>00009 <span class="comment">*/</span>
<a name="l00010"></a><a class="code" href="classclient.html#a4684cdbcdc4a3bd61631d974d0ce3dea">00010</a> <a class="code" href="classclient.html#a4684cdbcdc4a3bd61631d974d0ce3dea" title="Constructeur par défaut.">client::client</a>()
<a name="l00011"></a>00011 {
<a name="l00012"></a>00012     <a class="code" href="classbase_client_server.html#a6415a999d34d9969e6b7d7108df74c0f">IF_WINDOWS</a>(
<a name="l00013"></a>00013         <a class="code" href="classclient.html#adb571683580a7a0b2dbd6183e52d4dff" title="L&amp;#39;adresse du serveur.">c_serverAdress</a>.S_un.S_addr = inet_addr(<span class="stringliteral">&quot;127.0.0.1&quot;</span>);
<a name="l00014"></a>00014     )
<a name="l00015"></a>00015     IF_LINUX(
<a name="l00016"></a>00016         <a class="code" href="classclient.html#adb571683580a7a0b2dbd6183e52d4dff" title="L&amp;#39;adresse du serveur.">c_serverAdress</a>.s_addr = inet_addr(<span class="stringliteral">&quot;127.0.0.1&quot;</span>);
<a name="l00017"></a>00017     )
<a name="l00018"></a>00018 }
<a name="l00019"></a>00019 
<a name="l00020"></a>00020 
<a name="l00021"></a>00021 <span class="comment">/***************************************************************************/</span><span class="comment">/*!</span>
<a name="l00022"></a>00022 <span class="comment">* @fn client::~client()</span>
<a name="l00023"></a>00023 <span class="comment">* @brief Destructeur par défaut</span>
<a name="l00024"></a>00024 <span class="comment">* @note Déconnect le client</span>
<a name="l00025"></a>00025 <span class="comment">*/</span>
<a name="l00026"></a><a class="code" href="classclient.html#ad45e388579b8c0ffec6f29ed2c0c4de9">00026</a> <a class="code" href="classclient.html" title="Cette class permet de gérer facilement un client.">client</a>::~<a class="code" href="classclient.html#a4684cdbcdc4a3bd61631d974d0ce3dea" title="Constructeur par défaut.">client</a>()
<a name="l00027"></a>00027 {
<a name="l00028"></a>00028     <a class="code" href="classclient.html#a8d1188c4d73c355ca3233bd7efbedc75" title="Permet de se déconnecter au serveur.">disconnection</a>();
<a name="l00029"></a>00029 }
<a name="l00030"></a>00030 
<a name="l00031"></a>00031 
<a name="l00032"></a>00032 <span class="comment">/***************************************************************************/</span><span class="comment">/*!</span>
<a name="l00033"></a>00033 <span class="comment">* @fn bool client::connection()</span>
<a name="l00034"></a>00034 <span class="comment">* @brief Permet de se connecter au serveur</span>
<a name="l00035"></a>00035 <span class="comment">* @return True si connection réussi !</span>
<a name="l00036"></a>00036 <span class="comment">* @note Cette fonction est la seule a permettre la connection.&lt;br /&gt;</span>
<a name="l00037"></a>00037 <span class="comment">* TCP_NoDelay = true</span>
<a name="l00038"></a>00038 <span class="comment">*/</span>
<a name="l00039"></a><a class="code" href="classclient.html#aafb3e1157b7e1f3e81c09fe1c7866a82">00039</a> <span class="keywordtype">bool</span> <a class="code" href="classclient.html#aafb3e1157b7e1f3e81c09fe1c7866a82" title="Permet de se connecter au serveur.">client::connection</a>()
<a name="l00040"></a>00040 {
<a name="l00041"></a>00041     <span class="comment">// AF_INET, PF_INET := The Internet Protocol version 4 (IPv4) address family.</span>
<a name="l00042"></a>00042     <span class="comment">// AF_INET6, PF_INET6 := The Internet Protocol version 6 (IPv6) address family.</span>
<a name="l00043"></a>00043     <span class="comment">// AF_INET = Address Format, Internet = IP Addresses</span>
<a name="l00044"></a>00044     <span class="comment">// PF_INET = Packet Format, Internet = IP, TCP/IP or UDP/IP</span>
<a name="l00045"></a>00045     <span class="comment">// SOCK_STREAM := A socket type that provides sequenced, reliable, two-way, connection-based byte streams with an OOB data transmission mechanism. This socket type uses the Transmission Control Protocol (TCP) for the Internet address family (AF_INET or AF_INET6).</span>
<a name="l00046"></a>00046     <span class="comment">// SOCK_DGRAM := A socket type that supports datagrams, which are connectionless, unreliable buffers of a fixed (typically small) maximum length. This socket type uses the User Datagram Protocol (UDP) for the Internet address family (AF_INET or AF_INET6).</span>
<a name="l00047"></a>00047     <a class="code" href="classbase_client_server.html#adcdb18e66a3751fd8edbd5d1f65e8bd3" title="Le socket principal. ( c&amp;#39;est clui là quit sert pour l&amp;#39;écoute sur le port c_port )...">c_listenSocket</a> = socket(PF_INET, SOCK_STREAM, 0<span class="comment">/* Pas de protocole */</span>);
<a name="l00048"></a>00048     <span class="keywordflow">if</span>( <a class="code" href="classbase_client_server.html#adcdb18e66a3751fd8edbd5d1f65e8bd3" title="Le socket principal. ( c&amp;#39;est clui là quit sert pour l&amp;#39;écoute sur le port c_port )...">c_listenSocket</a> == INVALID_SOCKET ){
<a name="l00049"></a>00049         this-&gt;<a class="code" href="classclient.html#ad45e388579b8c0ffec6f29ed2c0c4de9" title="Destructeur par défaut.">~client</a>();
<a name="l00050"></a>00050         stdErrorE(<span class="stringliteral">&quot;Erreur(%d) lors de l&#39;ouverture du socket. Detail: &lt;%s&gt;&quot;</span>, SOCKET_REPPORT_ERROR, strerror(SOCKET_REPPORT_ERROR));
<a name="l00051"></a>00051     }
<a name="l00052"></a>00052 
<a name="l00053"></a>00053     <span class="comment">// Paramètrage du serveur</span>
<a name="l00054"></a>00054     <a class="code" href="classbase_client_server.html#a9a11cce8df298490560c391275736be9">c_addr</a>.sin_family       = AF_INET;          <span class="comment">// Address family</span>
<a name="l00055"></a>00055     <a class="code" href="classbase_client_server.html#a9a11cce8df298490560c391275736be9">c_addr</a>.sin_port         = htons(<a class="code" href="classbase_client_server.html#a2dea81cee139f918358e36b8650fa37e" title="&amp;lt; Temps d&amp;#39;attente au niveau du select">c_port</a>);    <span class="comment">// IP port ( The htons function converts a u_short from host to TCP/IP network byte order (which is big-endian).)</span>
<a name="l00056"></a>00056     <span class="comment">// The in_addr structure is the IPv4 equivalent of the IPv6-based in6_addr structure.</span>
<a name="l00057"></a>00057     <a class="code" href="classbase_client_server.html#a9a11cce8df298490560c391275736be9">c_addr</a>.sin_addr         = <a class="code" href="classclient.html#adb571683580a7a0b2dbd6183e52d4dff" title="L&amp;#39;adresse du serveur.">c_serverAdress</a>;
<a name="l00058"></a>00058     <span class="comment">// c_addr.sin_zero // padding ( packed )</span>
<a name="l00059"></a>00059 
<a name="l00060"></a>00060     <a class="code" href="classbase_client_server.html#a94f59ec6bf09f3c90f25e57781632df5">setTCP_NoDelay</a>( __TCP_NODELAY__ );
<a name="l00061"></a>00061 
<a name="l00062"></a>00062     <span class="keywordflow">if</span>( connect(<a class="code" href="classbase_client_server.html#adcdb18e66a3751fd8edbd5d1f65e8bd3" title="Le socket principal. ( c&amp;#39;est clui là quit sert pour l&amp;#39;écoute sur le port c_port )...">c_listenSocket</a>, (<a class="code" href="class___base_client_server_8h.html#ae334b73cedf7204187dce3f817576009">SOCKADDR</a> *)&amp;<a class="code" href="classbase_client_server.html#a9a11cce8df298490560c391275736be9">c_addr</a>, <span class="keyword">sizeof</span>(c_addr)) == SOCKET_ERROR ){
<a name="l00063"></a>00063         stdError(<span class="stringliteral">&quot;Erreur(%d) lors de la connection au serveur. Detail: &lt;%s&gt;&quot;</span>, SOCKET_REPPORT_ERROR, strerror(SOCKET_REPPORT_ERROR));
<a name="l00064"></a>00064         <a class="code" href="classbase_client_server.html#adcdb18e66a3751fd8edbd5d1f65e8bd3" title="Le socket principal. ( c&amp;#39;est clui là quit sert pour l&amp;#39;écoute sur le port c_port )...">c_listenSocket</a> = 0;
<a name="l00065"></a>00065         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00066"></a>00066     }
<a name="l00067"></a>00067 
<a name="l00068"></a>00068     <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00069"></a>00069 }
<a name="l00070"></a>00070 
<a name="l00071"></a>00071 
<a name="l00072"></a>00072 <span class="comment">/***************************************************************************/</span><span class="comment">/*!</span>
<a name="l00073"></a>00073 <span class="comment">* @fn void client::disconnection()</span>
<a name="l00074"></a>00074 <span class="comment">* @brief Permet de se déconnecter au serveur</span>
<a name="l00075"></a>00075 <span class="comment">*/</span>
<a name="l00076"></a><a class="code" href="classclient.html#a8d1188c4d73c355ca3233bd7efbedc75">00076</a> <span class="keywordtype">void</span> <a class="code" href="classclient.html#a8d1188c4d73c355ca3233bd7efbedc75" title="Permet de se déconnecter au serveur.">client::disconnection</a>()
<a name="l00077"></a>00077 {
<a name="l00078"></a>00078     <span class="comment">// Fermeture de la connection</span>
<a name="l00079"></a>00079     <span class="keywordflow">if</span>( <a class="code" href="classbase_client_server.html#adcdb18e66a3751fd8edbd5d1f65e8bd3" title="Le socket principal. ( c&amp;#39;est clui là quit sert pour l&amp;#39;écoute sur le port c_port )...">c_listenSocket</a> )
<a name="l00080"></a>00080         closesocket(<a class="code" href="classbase_client_server.html#adcdb18e66a3751fd8edbd5d1f65e8bd3" title="Le socket principal. ( c&amp;#39;est clui là quit sert pour l&amp;#39;écoute sur le port c_port )...">c_listenSocket</a>);
<a name="l00081"></a>00081         <span class="comment">//shutdown(c_listenSocket, SHUT_RDWR);// SHUT_RDWR = No more receptions or transmissions.</span>
<a name="l00082"></a>00082 
<a name="l00083"></a>00083     <a class="code" href="classbase_client_server.html#adcdb18e66a3751fd8edbd5d1f65e8bd3" title="Le socket principal. ( c&amp;#39;est clui là quit sert pour l&amp;#39;écoute sur le port c_port )...">c_listenSocket</a> = 0;
<a name="l00084"></a>00084 }
<a name="l00085"></a>00085 
<a name="l00086"></a>00086 
<a name="l00087"></a>00087 <span class="comment">/***************************************************************************/</span><span class="comment">/*!</span>
<a name="l00088"></a>00088 <span class="comment">* @fn bool client::is_connected()</span>
<a name="l00089"></a>00089 <span class="comment">* @brief Permet de savoir si l&#39;on est connecté au serveur</span>
<a name="l00090"></a>00090 <span class="comment">*/</span>
<a name="l00091"></a><a class="code" href="classclient.html#a23d55bd91048a867c3c1cb353de27869">00091</a> <span class="keywordtype">bool</span> <a class="code" href="classclient.html#a23d55bd91048a867c3c1cb353de27869" title="Permet de savoir si l&amp;#39;on est connecté au serveur.">client::is_connected</a>()
<a name="l00092"></a>00092 {
<a name="l00093"></a>00093     <span class="keywordflow">return</span> (<span class="keywordtype">bool</span>)<a class="code" href="classbase_client_server.html#adcdb18e66a3751fd8edbd5d1f65e8bd3" title="Le socket principal. ( c&amp;#39;est clui là quit sert pour l&amp;#39;écoute sur le port c_port )...">c_listenSocket</a>;
<a name="l00094"></a>00094 }
<a name="l00095"></a>00095 
<a name="l00096"></a>00096 
<a name="l00097"></a>00097 <span class="comment">/***************************************************************************/</span><span class="comment">/*!</span>
<a name="l00098"></a>00098 <span class="comment">* @fn void client::setServerAdress( const char ip[] )</span>
<a name="l00099"></a>00099 <span class="comment">* @brief Permet de définir le serveur où se connecter</span>
<a name="l00100"></a>00100 <span class="comment">* @param[in] ip L&#39;adresse IP du serveur où l&#39;on veut se connecter ( PAS DE NOM DE DOMAINE ! )</span>
<a name="l00101"></a>00101 <span class="comment">*/</span>
<a name="l00102"></a><a class="code" href="classclient.html#a6c40fcab76ed1d882a253a1bf8c33546">00102</a> <span class="keywordtype">void</span> <a class="code" href="classclient.html#a6c40fcab76ed1d882a253a1bf8c33546" title="Permet de définir le serveur où se connecter.">client::setServerAdress</a>( <span class="keyword">const</span> <span class="keywordtype">char</span> ip[] )
<a name="l00103"></a>00103 {
<a name="l00104"></a>00104     <span class="comment">// inet_ntoa();// Reverse IP -&gt; char IP[]</span>
<a name="l00105"></a>00105     <a class="code" href="classbase_client_server.html#a6415a999d34d9969e6b7d7108df74c0f">IF_WINDOWS</a>(
<a name="l00106"></a>00106         <a class="code" href="classclient.html#adb571683580a7a0b2dbd6183e52d4dff" title="L&amp;#39;adresse du serveur.">c_serverAdress</a>.S_un.S_addr = inet_addr(ip);
<a name="l00107"></a>00107     )
<a name="l00108"></a>00108     IF_LINUX(
<a name="l00109"></a>00109         <a class="code" href="classclient.html#adb571683580a7a0b2dbd6183e52d4dff" title="L&amp;#39;adresse du serveur.">c_serverAdress</a>.s_addr = inet_addr(ip);
<a name="l00110"></a>00110     )
<a name="l00111"></a>00111 }
<a name="l00112"></a>00112 
<a name="l00113"></a>00113 
<a name="l00114"></a>00114 <span class="comment">/***************************************************************************/</span><span class="comment">/*!</span>
<a name="l00115"></a>00115 <span class="comment">* @fn void client::setServerAdress( const IN_ADDR* ip )</span>
<a name="l00116"></a>00116 <span class="comment">* @brief Permet de définir le serveur où se connecter</span>
<a name="l00117"></a>00117 <span class="comment">* @param[in] ip L&#39;adresse IP du serveur où l&#39;on veut se connecter</span>
<a name="l00118"></a>00118 <span class="comment">*/</span>
<a name="l00119"></a><a class="code" href="classclient.html#a86755c2857b20a2740e63d1dba784e11">00119</a> <span class="keywordtype">void</span> <a class="code" href="classclient.html#a6c40fcab76ed1d882a253a1bf8c33546" title="Permet de définir le serveur où se connecter.">client::setServerAdress</a>( <span class="keyword">const</span> <a class="code" href="class___base_client_server_8h.html#a328d951616d1a7f289fef8e6b23a926b">IN_ADDR</a>* ip )
<a name="l00120"></a>00120 {
<a name="l00121"></a>00121     <a class="code" href="classclient.html#adb571683580a7a0b2dbd6183e52d4dff" title="L&amp;#39;adresse du serveur.">c_serverAdress</a> = *ip;
<a name="l00122"></a>00122 }
<a name="l00123"></a>00123 
<a name="l00124"></a>00124 
<a name="l00125"></a>00125 <span class="comment">/***************************************************************************/</span><span class="comment">/*!</span>
<a name="l00126"></a>00126 <span class="comment">* @fn const IN_ADDR* client::setServerHost( const char domain[] )</span>
<a name="l00127"></a>00127 <span class="comment">* @brief Permet de définir le serveur où se connecter</span>
<a name="l00128"></a>00128 <span class="comment">* @param[in] domain Le nom de domaine où se connecter. (ex: google.fr)</span>
<a name="l00129"></a>00129 <span class="comment">* @return NULL si bug</span>
<a name="l00130"></a>00130 <span class="comment">*/</span>
<a name="l00131"></a><a class="code" href="classclient.html#a70931a97daa1714bf9f36274e5be5c0f">00131</a> <span class="keyword">const</span> <a class="code" href="class___base_client_server_8h.html#a328d951616d1a7f289fef8e6b23a926b">IN_ADDR</a>* <a class="code" href="classclient.html#a70931a97daa1714bf9f36274e5be5c0f" title="Permet de définir le serveur où se connecter.">client::setServerHost</a>( <span class="keyword">const</span> <span class="keywordtype">char</span> domain[] )
<a name="l00132"></a>00132 {
<a name="l00133"></a>00133     <span class="comment">//inet_pton()// Linux IPv4, IPv6</span>
<a name="l00134"></a>00134 
<a name="l00135"></a>00135     <a class="code" href="class___base_client_server_8h.html#a00efd0fdd0cb87ebd4106b85293990ed">HOSTENT</a>* hostinfo = 0;
<a name="l00136"></a>00136 
<a name="l00137"></a>00137     hostinfo = gethostbyname(domain);
<a name="l00138"></a>00138     <span class="keywordflow">if</span>( !hostinfo ){
<a name="l00139"></a>00139        stdError(<span class="stringliteral">&quot;Unknown host %s&quot;</span>, domain);
<a name="l00140"></a>00140        <span class="keywordflow">return</span> 0;
<a name="l00141"></a>00141    }
<a name="l00142"></a>00142 
<a name="l00143"></a>00143     <a class="code" href="classclient.html#adb571683580a7a0b2dbd6183e52d4dff" title="L&amp;#39;adresse du serveur.">c_serverAdress</a> = *((<a class="code" href="class___base_client_server_8h.html#a328d951616d1a7f289fef8e6b23a926b">IN_ADDR</a> *)hostinfo-&gt;h_addr);
<a name="l00144"></a>00144 
<a name="l00145"></a>00145     <span class="keywordflow">return</span> &amp;<a class="code" href="classclient.html#adb571683580a7a0b2dbd6183e52d4dff" title="L&amp;#39;adresse du serveur.">c_serverAdress</a>;
<a name="l00146"></a>00146 }
<a name="l00147"></a>00147 
<a name="l00148"></a>00148 
<a name="l00149"></a>00149 <span class="comment">/***************************************************************************/</span><span class="comment">/*!</span>
<a name="l00150"></a>00150 <span class="comment">* @fn bool client::lookupConnection()</span>
<a name="l00151"></a>00151 <span class="comment">* @brief Permet de récupérer détecter l&#39;activiter sur le réseau</span>
<a name="l00152"></a>00152 <span class="comment">*/</span>
<a name="l00153"></a><a class="code" href="classclient.html#ae2d32defc7b1e99ef53d599d641a5335">00153</a> <span class="keywordtype">bool</span> <a class="code" href="classclient.html#ae2d32defc7b1e99ef53d599d641a5335" title="Permet de récupérer détecter l&amp;#39;activiter sur le réseau.">client::lookupConnection</a>()
<a name="l00154"></a>00154 {
<a name="l00155"></a>00155     <span class="comment">// Remise à 0 du fd read</span>
<a name="l00156"></a>00156     FD_ZERO(&amp;<a class="code" href="classbase_client_server.html#a72e8655cd3ede0bea9cdb934ff40fa42" title="Le fd qui est utiliser pour check les signaux en lecture.">c_rdfs</a>);
<a name="l00157"></a>00157 
<a name="l00158"></a>00158     <span class="comment">// Ajout du socket principal dans la liste des écoute non bloquante</span>
<a name="l00159"></a>00159     FD_SET(<a class="code" href="classbase_client_server.html#adcdb18e66a3751fd8edbd5d1f65e8bd3" title="Le socket principal. ( c&amp;#39;est clui là quit sert pour l&amp;#39;écoute sur le port c_port )...">c_listenSocket</a>, &amp;<a class="code" href="classbase_client_server.html#a72e8655cd3ede0bea9cdb934ff40fa42" title="Le fd qui est utiliser pour check les signaux en lecture.">c_rdfs</a>);
<a name="l00160"></a>00160 
<a name="l00161"></a>00161     <span class="comment">// Lecture du socket principal</span>
<a name="l00162"></a>00162     <span class="keywordflow">if</span>( select(<a class="code" href="classbase_client_server.html#adcdb18e66a3751fd8edbd5d1f65e8bd3" title="Le socket principal. ( c&amp;#39;est clui là quit sert pour l&amp;#39;écoute sur le port c_port )...">c_listenSocket</a>+1, &amp;<a class="code" href="classbase_client_server.html#a72e8655cd3ede0bea9cdb934ff40fa42" title="Le fd qui est utiliser pour check les signaux en lecture.">c_rdfs</a>, NULL, NULL, &amp;c_wait) == SOCKET_ERROR ){
<a name="l00163"></a>00163         stdError(<span class="stringliteral">&quot;Erreur(%d) lors de la lecture (select) du socket principal. Detail: &lt;%s&gt;&quot;</span>, SOCKET_REPPORT_ERROR, strerror(SOCKET_REPPORT_ERROR));
<a name="l00164"></a>00164         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00165"></a>00165     }
<a name="l00166"></a>00166 
<a name="l00167"></a>00167     <span class="comment">// On vérifit si new client</span>
<a name="l00168"></a>00168     <span class="keywordflow">if</span>( FD_ISSET(<a class="code" href="classbase_client_server.html#adcdb18e66a3751fd8edbd5d1f65e8bd3" title="Le socket principal. ( c&amp;#39;est clui là quit sert pour l&amp;#39;écoute sur le port c_port )...">c_listenSocket</a>, &amp;<a class="code" href="classbase_client_server.html#a72e8655cd3ede0bea9cdb934ff40fa42" title="Le fd qui est utiliser pour check les signaux en lecture.">c_rdfs</a>) )
<a name="l00169"></a>00169         <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00170"></a>00170 
<a name="l00171"></a>00171     <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00172"></a>00172 }
<a name="l00173"></a>00173 
<a name="l00174"></a>00174 
<a name="l00175"></a>00175 <span class="comment">/***************************************************************************/</span><span class="comment">/*!</span>
<a name="l00176"></a>00176 <span class="comment">* @fn int client::readServer( char* buffer, unsigned int bufferSize )</span>
<a name="l00177"></a>00177 <span class="comment">* @brief Récupère les données envoyées par le serveur</span>
<a name="l00178"></a>00178 <span class="comment">* @param[in,out] buffer La variables où seront stockées les données</span>
<a name="l00179"></a>00179 <span class="comment">* @param[in] bufferSize Taille du buffer</span>
<a name="l00180"></a>00180 <span class="comment">* @return Le nombre de byte reçut</span>
<a name="l00181"></a>00181 <span class="comment">*</span>
<a name="l00182"></a>00182 <span class="comment">* @note si retour = 0 =&gt; Client déconnecté (Le client est automatiquement viré de la liste dans ce cas la)&lt;br /&gt;</span>
<a name="l00183"></a>00183 <span class="comment">* En cas d&#39;erreur, le client sera déconnecté</span>
<a name="l00184"></a>00184 <span class="comment">*/</span>
<a name="l00185"></a><a class="code" href="classclient.html#a2ea117a6fd3515343481d4ea4d97eab4">00185</a> <span class="keywordtype">int</span> <a class="code" href="classclient.html#a2ea117a6fd3515343481d4ea4d97eab4" title="Récupère les données envoyées par le serveur.">client::readServer</a>( <span class="keywordtype">char</span>* buffer, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> bufferSize )
<a name="l00186"></a>00186 {
<a name="l00187"></a>00187     <span class="keywordtype">int</span> nbByte = <a class="code" href="classbase_client_server.html#a6eeb24edfb7b92dd6311817d848bb953" title="Récupère les données envoyées par un client.">baseClientServer::readClient</a>( <a class="code" href="classbase_client_server.html#adcdb18e66a3751fd8edbd5d1f65e8bd3" title="Le socket principal. ( c&amp;#39;est clui là quit sert pour l&amp;#39;écoute sur le port c_port )...">c_listenSocket</a>, buffer, bufferSize );
<a name="l00188"></a>00188     <span class="keywordflow">if</span>( !nbByte )
<a name="l00189"></a>00189         <a class="code" href="classclient.html#a8d1188c4d73c355ca3233bd7efbedc75" title="Permet de se déconnecter au serveur.">disconnection</a>();
<a name="l00190"></a>00190         <span class="comment">//stdError(&quot;Le serveur nous a deco !&quot;);</span>
<a name="l00191"></a>00191 
<a name="l00192"></a>00192     <span class="keywordflow">return</span> nbByte;
<a name="l00193"></a>00193 }
</pre></div></div>
</div>
<hr class="footer"/><address class="footer"><small>Généré le Fri Jan 21 2011 01:21:27 pour Bomberman par&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.1 </small></address>
</body>
</html>
